package cn.hanyx.coder.design.pattern.creational.singleton;

public class Singleton {
    private static Singleton instance = null;
    private final int paramA;
    private final int paramB;

    private Singleton(int paramA, int paramB) {
        this.paramA = paramA;
        this.paramB = paramB;
    }

    public synchronized static Singleton getInstance(int paramA, int paramB) {
        if (instance == null) {
            instance = new Singleton(paramA, paramB);
        }
        return instance;
    }

    @Override
    public String toString() {
        return "Singleton{" +
                "paramA=" + paramA +
                ", paramB=" + paramB +
                '}';
    }

    public static void main(String[] args) {

        Singleton singleton1 = Singleton.getInstance(10, 50);
        Singleton singleton2 = Singleton.getInstance(20, 30);

        System.out.println(singleton1);
        System.out.println(singleton2);

        ClassLoader.getSystemClassLoader();
    }
}

